<?php
            


/**
 * Author: cbw
 * Desc: 易宣优惠券
 * Time: 2022/11/11 10:49
 * Email: 17854288794@163.com
 */
$coupon_use_type = $_P['coupon_use_type'];
$coupon_mode_desc = $_P['coupon_mode_desc']?$_P['coupon_mode_desc']:'';
$coupon_txt_tmp = $_P['coupon_txt_tmp']?$_P['coupon_txt_tmp']:'使用现金优惠券抵#fee元';
$default_right_icon_bg = 'https://css2020.yixuan.net/2020css/yx2020/images/coupon.png';
if ($coupon_use_type==3){
    $default_right_icon_bg = 'https://css2020.yixuan.net/2020css/yx2020/images/coupon2.png';
    if ($coupon_txt_tmp=='使用现金优惠券抵#fee元'){
        $coupon_txt_tmp = '使用现金优惠券最高抵#fee元';
    }
}
$coupon_offline_tips = $_P['coupon_offline_tips']?$_P['coupon_offline_tips']:'(进店可用,详情联系客服)';
$coupon_offline_right_txt_top = $_P['coupon_offline_right_txt_top']?$_P['coupon_offline_right_txt_top']:'进店可用';
$coupon_offline_btn = $_P['coupon_offline_btn']?$_P['coupon_offline_btn']:'进店可用';


$coupon_right_icon_bg = $_P['coupon_right_icon_bg']?tomedia($_P['coupon_right_icon_bg']):$default_right_icon_bg;
$coupon_right_txt_size = $_P['coupon_right_txt_size']?$_P['coupon_right_txt_size']:20;
$coupon_right_txt_color = $_P['coupon_right_txt_color']?$_P['coupon_right_txt_color']:'#ce3817';
$coupon_right_txt_top = $_P['coupon_right_txt_top']?$_P['coupon_right_txt_top']:26;
$coupon_right_txt_left = $_P['coupon_right_txt_left']?$_P['coupon_right_txt_left']:$coupon_use_type==3?30:28;
$coupon_list_bg = $_P['coupon_list_bg']?tomedia($_P['coupon_list_bg']):'';
if (!$coupon_mode_desc){
    if ($coupon_use_type==0){
        $coupon_mode_desc = '只能使用一张最大金额优惠券用于付款抵扣';
    }elseif ($coupon_use_type==1){
        $coupon_mode_desc = '可叠加使用多张可用优惠券用于付款抵扣';
    }else{
        $coupon_mode_desc = '可使用对应满减金额的优惠券用于付款抵扣';
    }
}
$coupon_use_type_arr = ['只能使用一张最大金额优惠券用于付款抵扣','可叠加使用多张可用优惠券用于付款抵扣','可使用对应满减金额的优惠券用于付款抵扣'];
if (in_array($coupon_mode_desc,$coupon_use_type_arr)){
    if ($coupon_use_type==0){
        $coupon_mode_desc = '只能使用一张最大金额优惠券用于付款抵扣';
    }elseif ($coupon_use_type==1){
        $coupon_mode_desc = '可叠加使用多张可用优惠券用于付款抵扣';
    }else{
        $coupon_mode_desc = '可使用对应满减金额的优惠券用于付款抵扣';
    }
}
//
//require_once YX_PLUGIN_CORE . 'inc/plugin_model.php';
//require_once get_path('plugin/coupon/core/model.php');
//$total = CouponModel::userCouponListData($themeid,0,0,0,0,0,0,'',0,5000,'','',0,true);
//if ($total>0 && $config_old['coupon_use_type']!=$coupon_use_type){
//    $coupon_use_type = $config_old['coupon_use_type'];
//    return_msg('优惠券已有领取记录，优惠券使用模式无法更改');
//}


$tmp_config = [
    'coupon_use_type'=>$coupon_use_type,
    'coupon_mode_desc'=>$coupon_mode_desc,
    'coupon_txt_tmp'=>$coupon_txt_tmp,
    'coupon_right_icon_bg'=>$coupon_right_icon_bg,
    'coupon_right_txt_size'=>$coupon_right_txt_size,
    'coupon_right_txt_color'=>$coupon_right_txt_color,
    'coupon_right_txt_top'=>$coupon_right_txt_top,
    'coupon_right_txt_left'=>$coupon_right_txt_left,
    'coupon_list_bg'=>$coupon_list_bg,
    'coupon_offline_tips'=>$coupon_offline_tips,
    'coupon_offline_right_txt_top'=>$coupon_offline_right_txt_top,
    'coupon_offline_btn'=>$coupon_offline_btn,
];
$config =array_merge($config,$tmp_config);